package tools.FutureMode;

/**
 * @author Kevin
 * @date 2020/4/14 20:54
 */
public class RealData implements Data {
    protected final String result;

    //RealData的构造可能很慢，需要用户等待很久，这里使用sleep模拟
    public RealData(String para) throws InterruptedException {
        StringBuffer sb = new StringBuffer();
        for (int i= 0 ; i < 10; i++) {
            sb.append(para);
            try {
                //这里使用sleep，代替一个很慢的操作过程
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        result = sb.toString();
    }
    @Override
    public String getResult() {
        return result;
    }
}
